home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / benchmarks / itc / gcc / rtl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-30  |  16.0 KB  |  460 lines

  1. /* Register Transfer Language (RTL) definitions for GNU C-Compiler
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY.  No author or distributor
  8. accepts responsibility to anyone for the consequences of using it
  9. or for whether it serves any particular purpose or works at all,
  10. unless he says so in writing.  Refer to the GNU CC General Public
  11. License for full details.
  12.  
  13. Everyone is granted permission to copy, modify and redistribute
  14. GNU CC, but only under the conditions described in the
  15. GNU CC General Public License.   A copy of this license is
  16. supposed to have been given to you along with GNU CC so you
  17. can know your rights and responsibilities.  It should be in a
  18. file named COPYING.  Among other things, the copyright notice
  19. and this notice must be preserved on all copies.  */
  20.  
  21.  
  22. /* Register Transfer Language EXPRESSIONS CODES */
  23.  
  24. #define RTX_CODE    enum rtx_code
  25. enum rtx_code  {
  26.  
  27. #define DEF_RTL_EXPR(ENUM, NAME, FORMAT)   ENUM ,
  28. #include "rtl.def"        /* rtl expressions are documented here */
  29. #undef DEF_RTL_EXPR
  30.  
  31.   LAST_AND_UNUSED_RTX_CODE};    /* A convienent way to get a value for
  32.                    NUM_RTX_CODE.
  33.                    Assumes default enum value assignement.  */
  34.  
  35. #define NUM_RTX_CODE ((int)LAST_AND_UNUSED_RTX_CODE)
  36.                 /* The cast here, saves many elsewhere.  */
  37.  
  38. extern int rtx_length[];
  39. #define GET_RTX_LENGTH(CODE)        (rtx_length[(int)(CODE)])
  40.  
  41. extern char *rtx_name[];
  42. #define GET_RTX_NAME(CODE)        (rtx_name[(int)(CODE)])
  43.  
  44. extern char *rtx_format[];
  45. #define GET_RTX_FORMAT(CODE)        (rtx_format[(int)(CODE)])
  46.  
  47.  
  48. /* Get the definition of `enum machine_mode' */
  49.  
  50. #ifndef HAVE_MACHINE_MODES
  51.  
  52. #define DEF_MACHMODE(SYM, NAME, TYPE, SIZE, UNIT)  SYM,
  53.  
  54. enum machine_mode {
  55. #include "machmode.def"
  56. MAX_MACHINE_MODE };
  57.  
  58. #undef DEF_MACHMODE
  59.  
  60. #define HAVE_MACHINE_MODES
  61.  
  62. #endif /* not HAVE_MACHINE_MODES */
  63.  
  64. #ifndef NUM_MACHINE_MODES
  65. #define NUM_MACHINE_MODES (int) MAX_MACHINE_MODE
  66. #endif
  67.  
  68. /* Get the name of mode MODE as a string.  */
  69.  
  70. extern char *mode_name[];
  71. #define GET_MODE_NAME(MODE)        (mode_name[(int)(MODE)])
  72.  
  73. enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT,
  74.           MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MODE_FUNCTION };
  75.  
  76. /* Get the general kind of object that mode MODE represents
  77.    (integer, floating, complex, etc.)  */
  78.  
  79. extern enum mode_class mode_class[];
  80. #define GET_MODE_CLASS(MODE)        (mode_class[(int)(MODE)])
  81.  
  82. /* Get the size in bytes of an object of mode MODE.  */
  83.  
  84. extern int mode_size[];
  85. #define GET_MODE_SIZE(MODE)        (mode_size[(int)(MODE)])
  86.  
  87. /* Get the size in bytes of the basic parts of an object of mode MODE.  */
  88.  
  89. extern int mode_unit_size[];
  90. #define GET_MODE_UNIT_SIZE(MODE)    (mode_unit_size[(int)(MODE)])
  91.  
  92. /* Get the size in bits of an object of mode MODE.  */
  93.  
  94. #define GET_MODE_BITSIZE(MODE)  (BITS_PER_UNIT * mode_size[(int)(MODE)])
  95.  
  96. /* Get a bitmask containing 1 for all bits in a word
  97.    that fit within mode MODE.  */
  98.  
  99. #define GET_MODE_MASK(MODE)  \
  100.    ((GET_MODE_BITSIZE (MODE) >= HOST_BITS_PER_INT)  \
  101.     ? -1 : ((1 << GET_MODE_BITSIZE (MODE)) - 1))
  102.  
  103. /* Common union for an element of an rtx.  */
  104.  
  105. typedef union rtunion_def
  106. {
  107.   int rtint;
  108.   char *rtstr;
  109.   struct rtx_def *rtx;
  110.   struct rtvec_def *rtvec;
  111.   enum machine_mode rttype;
  112. } rtunion;
  113.  
  114. /* RTL expression ("rtx").  */
  115.  
  116. typedef struct rtx_def
  117. {
  118. #ifdef SHORT_ENUM_BUG
  119.   unsigned short code;
  120. #else
  121.   /* The kind of expression this is.  */
  122.   enum rtx_code code : 16;
  123. #endif
  124.   /* The kind of value the expression has.  */
  125.   enum machine_mode mode : 8;
  126.   /* 1 in an INSN if it can alter flow of control
  127.      within this function.  Not yet used!  */
  128.   unsigned int jump : 1;
  129.   /* 1 in an INSN if it can call another function.  Not yet used!  */
  130.   unsigned int call : 1;
  131.   /* 1 in a MEM or REG if value of this expression will never change
  132.      during the current function, even though it is not
  133.      manifestly constant.
  134.      1 in a SYMBOL_REF if it addresses something in the per-function
  135.      constants pool.  */
  136.   unsigned int unchanging : 1;
  137.   /* 1 in a MEM expression if contents of memory are volatile.  */
  138.   /* 1 in an INSN, CALL_INSN, JUMP_INSN, CODE_LABEL or BARRIER
  139.      if it is deleted.  */
  140.   /* 1 in a REG expression if corresponds to a variable declared by the user.
  141.      0 for an internally generated temporary.  */
  142.   unsigned int volatil : 1;
  143.   /* 1 in a MEM referring to a field of a structure (not a union!).
  144.      0 if the MEM was a variable or the result of a * operator in C;
  145.      1 if it was the result of a . or -> operator (on a struct) in C.  */
  146.   unsigned int in_struct : 1;
  147.   /* 1 if this rtx is used.  This is used for copying shared structure.
  148.      See `unshare_all_rtl'.
  149.      This bit is used to detect that event.  */
  150.   unsigned int used : 1;
  151.   /* Nonzero if this rtx came from procedure integration.
  152.      In a REG, nonzero means this reg refers to the return value
  153.      of the current function.  */
  154.   unsigned integrated : 1;
  155.   /* The first element of the operands of this rtx.
  156.      The number of operands and their types are controlled
  157.      by the `code' field, according to rtl.def.  */
  158.   rtunion fld[1];
  159. } *rtx;
  160.  
  161. #define NULL_RTX (rtx) NULL
  162.  
  163. /* Define macros to access the `code' field of the rtx.  */
  164.  
  165. #ifdef SHORT_ENUM_BUG
  166. #define GET_CODE(RTX)        ((enum rtx_code) ((RTX)->code))
  167. #define PUT_CODE(RTX, CODE)    ((RTX)->code = ((short) (CODE)))
  168. #else
  169. #define GET_CODE(RTX)        ((RTX)->code)
  170. #define PUT_CODE(RTX, CODE)    ((RTX)->code = (CODE))
  171. #endif
  172.  
  173. #define GET_MODE(RTX)        ((RTX)->mode)
  174. #define PUT_MODE(RTX, MODE)    ((RTX)->mode = (MODE))
  175.  
  176. /* RTL vector.  These appear inside RTX's when there is a need
  177.    for a variable number of things.  The principle use is inside
  178.    PARALLEL expressions.  */
  179.  
  180. typedef struct rtvec_def{
  181.   unsigned num_elem;        /* number of elements */
  182.   rtunion elem[1];
  183. } *rtvec;
  184.  
  185. #define NULL_RTVEC (rtvec) NULL
  186.  
  187. #define GET_NUM_ELEM(RTVEC)        ((RTVEC)->num_elem)
  188. #define PUT_NUM_ELEM(RTVEC, NUM)    ((RTVEC)->num_elem = (unsigned) NUM)
  189.  
  190. /* 1 if X is a REG.  */
  191.  
  192. #define REG_P(X) (GET_CODE (X) == REG)
  193.  
  194. /* 1 if X is a constant value that is an integer.  */
  195.  
  196. #define CONSTANT_P(X)   \
  197.   (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF        \
  198.    || GET_CODE (X) == CONST_INT                        \
  199.    || GET_CODE (X) == CONST)
  200.  
  201. /* General accessor macros for accessing the fields of an rtx.  */
  202.  
  203. #define XEXP(RTX, N)    ((RTX)->fld[N].rtx)
  204. #define XINT(RTX, N)    ((RTX)->fld[N].rtint)
  205. #define XSTR(RTX, N)    ((RTX)->fld[N].rtstr)
  206. #define XVEC(RTX, N)    ((RTX)->fld[N].rtvec)
  207. #define XVECLEN(RTX, N)    ((RTX)->fld[N].rtvec->num_elem)
  208. #define XVECEXP(RTX,N,M)((RTX)->fld[N].rtvec->elem[M].rtx)
  209.  
  210. /* ACCESS MACROS for particular fields of insns.  */
  211.  
  212. /* Holds a unique number for each insn.
  213.    These are not necessarily sequentially increasing.  */
  214. #define INSN_UID(INSN)    ((INSN)->fld[0].rtint)
  215.  
  216. /* Chain insns together in sequence.  */
  217. #define PREV_INSN(INSN)    ((INSN)->fld[1].rtx)
  218. #define NEXT_INSN(INSN)    ((INSN)->fld[2].rtx)
  219.  
  220. /* The body of an insn.  */
  221. #define PATTERN(INSN)    ((INSN)->fld[3].rtx)
  222.  
  223. /* Code number of instruction, from when it was recognized.
  224.    -1 means this instruction has not been recognized yet.  */
  225. #define INSN_CODE(INSN) ((INSN)->fld[4].rtint)
  226.  
  227. /* Set up in flow.c; empty before then.
  228.    Holds a chain of INSN_LIST rtx's whose first operands point at
  229.    previous insns with direct data-flow connections to this one.
  230.    That means that those insns set variables whose next use is in this insn.
  231.    They are always in the same basic block as this insn.  */
  232. #define LOG_LINKS(INSN)        ((INSN)->fld[5].rtx)
  233.  
  234. /* Holds a list of notes on what this insn does to various REGs.
  235.    It is a chain of EXPR_LIST rtx's, where the second operand
  236.    is the chain pointer and the first operand is the REG being described.
  237.    The mode field of the EXPR_LIST contains not a real machine mode
  238.    but a value that says what this note says about the REG:
  239.      REG_DEAD means that the REG dies in this insn.
  240.      REG_INC means that the REG is autoincremented or autodecremented.
  241.    Note that one insn can have both REG_DEAD and REG_INC for the same register
  242.    if the register is preincremented or predecremented in the insn
  243.    and not needed afterward.  This can probably happen.
  244.      REG_EQUIV describes the insn as a whole; it says that the
  245.    insn sets a register to a constant value or to be equivalent to
  246.    a memory address.  If the
  247.    register is spilled to the stack then the constant value
  248.    should be substituted for it.  The contents of the REG_EQUIV
  249.    is the constant value or memory address, which may be different
  250.    from the source of the SET although it has the same value. 
  251.      REG_EQUAL is like REG_EQUIV except that the destination
  252.    is only momentarily equal to the specified rtx.  Therefore, it
  253.    cannot be used for substitution; but it can be used for cse.
  254.      REG_RETVAL means that this insn copies the return-value of
  255.    a library call out of the hard reg for return values.  This note
  256.    is actually an INSN_LIST and it points to the first insn involved
  257.    in setting up arguments for the call.  flow.c uses this to delete
  258.    the entire library call when its result is dead.
  259.      REG_WAS_0 says that the register set in this insn held 0 before the insn.
  260.    The contents of the note is the insn that stored the 0.
  261.    If that insn is deleted or patched to a NOTE, the REG_WAS_0 is inoperative.
  262.    The REG_WAS_0 note is actually an INSN_LIST, not an EXPR_LIST.  */
  263.  
  264. #define REG_NOTES(INSN)    ((INSN)->fld[6].rtx)
  265.  
  266. enum reg_note { REG_DEAD = 1, REG_INC = 2, REG_EQUIV = 3, REG_WAS_0 = 4,
  267.         REG_EQUAL = 5, REG_RETVAL = 6 };
  268.  
  269. /* Extract the reg-note kind from an EXPR_LIST.  */
  270. #define REG_NOTE_KIND(LINK) ((enum reg_note) GET_MODE (LINK))
  271.  
  272. /* The label-number of a code-label.  The assembler label
  273.    is made from `L' and the label-number printed in decimal.
  274.    Label numbers are unique in a compilation.  */
  275. #define CODE_LABEL_NUMBER(INSN)    ((INSN)->fld[3].rtint)
  276.  
  277. #define LINE_NUMBER NOTE
  278.  
  279. /* In a NOTE that is a line number, this is a string for the file name
  280.    that the line is in.  */
  281.  
  282. #define NOTE_SOURCE_FILE(INSN)  ((INSN)->fld[3].rtstr)
  283.  
  284. /* In a NOTE that is a line number, this is the line number.
  285.    Other kinds of NOTEs are identified by negative numbers here.  */
  286. #define NOTE_LINE_NUMBER(INSN) ((INSN)->fld[4].rtint)
  287.  
  288. /* Codes that appear in the NOTE_LINE_NUMBER field
  289.    for kinds of notes that are not line numbers.  */
  290.  
  291. #define NOTE_INSN_FUNCTION_BEG 0
  292. #define NOTE_INSN_DELETED -1
  293. #define NOTE_INSN_BLOCK_BEG -2
  294. #define NOTE_INSN_BLOCK_END -3
  295. #define NOTE_INSN_LOOP_BEG -4
  296. #define NOTE_INSN_LOOP_END -5
  297. /* This kind of note is generated at the end of the function body,
  298.    just before the return insn or return label.
  299.    In an optimizing compilation it is deleted by the first jump optimization,
  300.    after enabling that optimizer to determine whether control can fall
  301.    off the end of the function body without a return statement.  */
  302. #define NOTE_INSN_FUNCTION_END -6
  303. /* This kind of note is generated just after each call to `setjmp', et al.  */
  304. #define NOTE_INSN_SETJMP -7
  305.  
  306. #define NOTE_DECL_NAME(INSN) ((INSN)->fld[3].rtstr)
  307. #define NOTE_DECL_CODE(INSN) ((INSN)->fld[4].rtint)
  308. #define NOTE_DECL_RTL(INSN) ((INSN)->fld[5].rtx)
  309. #define NOTE_DECL_IDENTIFIER(INSN) ((INSN)->fld[6].rtint)
  310. #define NOTE_DECL_TYPE(INSN) ((INSN)->fld[7].rtint)
  311.  
  312. /* In jump.c, each label contains a count of the number
  313.    of LABEL_REFs that point at it, so unused labels can be deleted.  */
  314. #define LABEL_NUSES(LABEL) ((LABEL)->fld[4].rtint)
  315.  
  316. /* In jump.c, each JUMP_INSN can point to a label that it can jump to,
  317.    so that if the JUMP_INSN is deleted, the label's LABEL_NUSES can
  318.    be decremented and possibly the label can be deleted.  */
  319. #define JUMP_LABEL(INSN)   ((INSN)->fld[7].rtx)
  320.  
  321. /* Once basic blocks are found in flow.c,
  322.    each CODE_LABEL starts a chain that goes through
  323.    all the LABEL_REFs that jump to that label.
  324.    The chain eventually winds up at the CODE_LABEL; it is circular.  */
  325. #define LABEL_REFS(LABEL) ((LABEL)->fld[4].rtx)
  326.  
  327. /* This is the field in the LABEL_REF through which the circular chain
  328.    of references to a particular label is linked.
  329.    This chain is set up in flow.c.  */
  330.  
  331. #define LABEL_NEXTREF(REF) ((REF)->fld[1].rtx)
  332.  
  333. /* Once basic blocks are found in flow.c,
  334.    Each LABEL_REF points to its containing instruction with this field.  */
  335.  
  336. #define CONTAINING_INSN(RTX) ((RTX)->fld[2].rtx)
  337.  
  338. /* For a REG rtx, REGNO extracts the register number.  */
  339.  
  340. #define REGNO(RTX) ((RTX)->fld[0].rtint)
  341.  
  342. /* For a REG rtx, REG_FUNCTION_VALUE_P is nonzero if the reg
  343.    is the current function's return value.  */
  344.  
  345. #define REG_FUNCTION_VALUE_P(RTX) ((RTX)->integrated)
  346.  
  347. /* For a CONST_INT rtx, INTVAL extracts the integer.  */
  348.  
  349. #define INTVAL(RTX) ((RTX)->fld[0].rtint)
  350.  
  351. /* For a SUBREG rtx, SUBREG_REG extracts the value we want a subreg of.
  352.    SUBREG_WORD extracts the word-number.  */
  353.  
  354. #define SUBREG_REG(RTX) ((RTX)->fld[0].rtx)
  355. #define SUBREG_WORD(RTX) ((RTX)->fld[1].rtint)
  356.  
  357. /* For a SET rtx, SET_DEST is the place that is set
  358.    and SET_SRC is the value it is set to.  */
  359. #define SET_DEST(RTX) ((RTX)->fld[0].rtx)
  360. #define SET_SRC(RTX) ((RTX)->fld[1].rtx)
  361.  
  362. /* For an INLINE_HEADER rtx, FIRST_FUNCTION_INSN is the first insn
  363.    of the function that is not involved in copying parameters to
  364.    pseudo-registers.  FIRST_PARM_INSN is the very first insn of
  365.    the function, including the parameter copying.
  366.    We keep this around in case we must splice
  367.    this function into the assembly code at the end of the file.
  368.    FIRST_LABELNO is the first label number used by the function (inclusive).
  369.    LAST_LABELNO is the last label used by the function (exclusive).
  370.    MAX_REGNUM is the largest pseudo-register used by that function.
  371.  
  372.    We want this to lay down like an INSN.  The PREV_INSN field
  373.    is always NULL.  The NEXT_INSN field always points to the
  374.    first function insn of the function being squirreled away.  */
  375.  
  376. #define FIRST_FUNCTION_INSN(RTX) ((RTX)->fld[2].rtx)
  377. #define FIRST_PARM_INSN(RTX) ((RTX)->fld[3].rtx)
  378. #define FIRST_LABELNO(RTX) ((RTX)->fld[4].rtint)
  379. #define LAST_LABELNO(RTX) ((RTX)->fld[5].rtint)
  380. #define MAX_PARMREG(RTX) ((RTX)->fld[6].rtint)
  381. #define MAX_REGNUM(RTX) ((RTX)->fld[7].rtint)
  382. #define FUNCTION_ARGS_SIZE(RTX) ((RTX)->fld[8].rtint)
  383.  
  384. /* Generally useful functions.  */
  385.  
  386. extern rtx rtx_alloc ();
  387. extern rtvec rtvec_alloc ();
  388. extern rtx find_reg_note ();
  389. extern rtx gen_rtx ();
  390. extern rtx copy_rtx ();
  391. extern rtvec gen_rtvec ();
  392. extern rtvec gen_rtvec_v ();
  393. extern rtx gen_reg_rtx ();
  394. extern rtx gen_label_rtx ();
  395. extern rtx gen_inline_header_rtx ();
  396. extern rtx gen_lowpart ();
  397. extern rtx gen_highpart ();
  398. extern int subreg_lowpart_p ();
  399. extern rtx make_safe_from ();
  400. extern rtx memory_address ();
  401. extern rtx get_insns ();
  402. extern rtx get_last_insn ();
  403. extern rtx gen_sequence ();
  404. extern rtx expand_expr ();
  405. extern rtx output_constant_def ();
  406. extern rtx immed_real_const ();
  407. extern rtx force_const_double_mem ();
  408. extern rtx force_const_mem ();
  409. extern rtx get_parm_real_loc ();
  410. extern rtx assign_stack_local ();
  411. extern rtx protect_from_queue ();
  412. extern void emit_queue ();
  413. extern rtx emit_move_insn ();
  414. extern rtx emit_insn ();
  415. extern rtx emit_jump_insn ();
  416. extern rtx emit_call_insn ();
  417. extern rtx emit_insn_before ();
  418. extern rtx emit_insn_after ();
  419. extern void emit_label ();
  420. extern void emit_barrier ();
  421. extern rtx emit_note ();
  422. extern rtx prev_real_insn ();
  423. extern rtx next_real_insn ();
  424. extern rtx next_nondeleted_insn ();
  425. extern rtx plus_constant ();
  426. extern rtx find_equiv_reg ();
  427. extern rtx delete_insn ();
  428. extern rtx adj_offsetable_operand ();
  429.  
  430. extern int emit_to_sequence;
  431.  
  432. extern int asm_noperands ();
  433. extern char *decode_asm_operands ();
  434.  
  435. #ifdef BITS_PER_WORD
  436. /* Conditional is to detect when config.h has been included.  */
  437. extern enum reg_class reg_preferred_class ();
  438. #endif
  439.  
  440. extern rtx get_first_nonparm_insn ();
  441.  
  442. /* Standard pieces of rtx, to be substituted directly into things.  */
  443. extern rtx pc_rtx;
  444. extern rtx cc0_rtx;
  445. extern rtx const0_rtx;
  446. extern rtx const1_rtx;
  447. extern rtx fconst0_rtx;
  448. extern rtx dconst0_rtx;
  449.  
  450. /* All references to certain hard regs, except those created
  451.    by allocating pseudo regs into them (when that's possible),
  452.    go through these unique rtx objects.  */
  453. extern rtx stack_pointer_rtx;
  454. extern rtx frame_pointer_rtx;
  455. extern rtx arg_pointer_rtx;
  456. extern rtx struct_value_rtx;
  457. extern rtx struct_value_incoming_rtx;
  458. extern rtx static_chain_rtx;
  459. extern rtx static_chain_incoming_rtx;
  460.